<%@ page import="java.util.LinkedList, model.subjects.Subject, model.subjects.Person, model.subjects.Enterprise" language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <jsp:useBean id="results" scope="request" type="java.util.LinkedList<Subject>"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>MainPage</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>

<script type="text/javascript" src="static/js/javascript.js"></script>

</head>
<body>



<a href='http://imbi.ld.ttu.ee/tomcat_webapp_logs/t103755_subjekt/log.txt'>loggid</a> ||<a href="LoginServlet?action=logout">Logi välja</a> 


<ul>
<a href='LoginServlet?action=login'>Otsing</a> || 
<a href='s?action=display_add_person'>Lisa Isikuid</a> || 
<a href='s?action=display_add_enterprise'>Lisa ettevõtteid</a> || 

</ul>

<%
/*

out.println("<table bgcolor=eeeeee border=1><tr><td>");
out.println("kasutaja:<b><font color=red>");
out.println((String)session.getAttribute("username")); 
out.println("</font></b><br>");
out.println("session id:<b>"+session.getId()+"</b>"); 
out.println("<br>");
out.println("Kasutaja id (andmebaasist voetud, salvestatud sessiooni):<b>" + ((String)session.getAttribute("user")) + "</b>"); 
Vaata control.PageControl.java lähtekoodi, sealt leiad, 
kuidas saadakse sessiooni atribuudi [user] väärtus andmebaasist 

out.println("</td></tr></table>");
*/


%>






<form action="s?action=search" method="post" ><table  bgcolor='#C0C0C0' ><tr><td>Subjekti tüüp:</td><td> <select id="MainPageSelectField"><option value='all_types'>kõik tüübid</option><option value='person'>Isik</option><option value='enterprise'>ettevõte</option><option value='customer'>klient</option><option value='employee'>töötaja</option></select><br/></td></tr>
<tr><td>Eesnimi :</td><td><input type='text' name='first_name' ><br/></td></tr>
 
<tr><td>Nimi : </td><td><input type='text' name='name' ><br/></td></tr>
<!--  <tr><td>Kliendi huvialad: </td><td><input type='text' id='clients_interest' ><br/></td></tr>
<tr><td>Allahindluse %: </td><td><input type='number' id='discount' ><br/></td></tr>-->
<tr><td>---------------</td><td>

<tr><td>Riik : </td><td><input type='text' name='country' ><br/></td></tr>
<tr><td>Maakond : </td><td><input type='text' name='county' ><br/></td></tr>
<tr><td>Linn: </td><td><input type='text' name='town_village' ><br/></td></tr>
<tr><td>Aadress: </td><td><input type='text' name='street_address' ><br/></td></tr>
<tr><td>Postiindeks: </td><td><input type='text' name='zipcode' ><br/></td></tr>

<tr><td>---------------</td><td>

<tr><td>Kontakt: </td><td><input type='text' name='contact' ><br/></td></tr>


 
 
<!--  <tr><td></td><td><button onclick='search_people()'>Otsi</button></td></tr></table>-->
<tr><td></td><td><button type="submit" >Otsi</button></td></tr></table></form>
<br>


<div id="vormi_vastus">

<%

if(!results.isEmpty()){
	out.println("<table><tr><td>Subjekti id</td><td>Nimi</td><td></td></tr>");
	for(Subject s: results){
		out.println("<tr>");
		out.println("<td>"+s.getId()+"</td>");
		out.println("<td>"+s.getName()+"</td>");
		if(s instanceof Person){
			out.println("<td><a href=\"s?action=display_modify_person&id="+s.getId()+"\">Muuda</a></td>");
		}else{
			out.println("<td><a href=\"s?action=display_modify_enterprise&id="+s.getId()+"\">Muuda</a></td>");
		}
		out.println("</tr>");
	}
	
}


%>
</table>
</div>











</body>
</html>